package com.hsc.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author
 * @date 2025-07-27
 * @Description * **作用1：**
 * * `@EnableAutoConfiguration` + main方法
 * * 配置并启动springboot程序
 * * 因为引入了web依赖，web依赖中由内置了（springmvc + tomcat），所以最终也是启动了springmvc程序
 * <p>
 * * **作用2：**
 * * `@RestController` + `@RequestMapping` + home()
 * * 测试springmvc请求映射
 * * `@RestController` = `@Controller` + `@ResponseBody` (直接响应)
 */
@EnableAutoConfiguration //配置并启动了springboot 项目
@RestController
public class MyApplication {
    public static void main(String[] args) {
        // 加载配置类MyApplication
        ApplicationContext applicationContext = SpringApplication.run(MyApplication.class);
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
    }

    @RequestMapping("/")
    public String home() {
        return "success spring boot";
    }
}
